import React from 'react';
import { useAccess, Access } from 'umi';

type PermissionWrapperProps = {
  name: string;
};

const PermissionWrapper: React.FC<PermissionWrapperProps> = (props) => {
  const { name, children } = props;
  const access = useAccess();
  return (
    <Access accessible={access.btnFilter(name)} fallback={null}>
      {children}
    </Access>
  );
};

export default PermissionWrapper;
